<template>
    <!-- 头部搜索框 start -->
    <nav class="nav-box">
        <div class="nav-input">
            <input id="userInput" type="text" v-model="wd" @blur="showBtn=false" @focus="showBtn=true" />
        </div>
        <div v-show="showBtn" class="nav-btn">
            <span @mousedown="goToPage()">搜索</span>
            <!-- <router-link :to="`/films?search=${wd}`" @mousedown="fun1">搜索</router-link> -->
        </div>
    </nav>
    <!-- 头部搜索框 end -->
</template>
<script>
export default {
    data(){
        return {
            showBtn:false,
            wd:""
        }
    },
    methods:{
        goToPage(){
            // 页面切换 == 通过编程式导航完成操作
            // console.log(this);
            // this.$router.push("/films?search="+this.wd);
            this.$router.push({
                // path:"/films",
                name:"films",
                query:{
                    search:this.wd
                }
            });
            this.wd = "";
            
        }
    }


}
</script>
<style lang="less" scoped>
.nav-box {
    height: @topHeight;
    line-height: @topHeight;
    background-color: @white;
    border-bottom: 1px solid @gray-light;
    display: flex;
    flex-flow: row nowrap;
    justify-content: center;
    box-sizing: border-box;
    > .nav-input {
        flex-grow: 3;
        padding: 0rem 0.2rem;
        box-sizing: border-box;
        > input[type="text"] {
            box-sizing: border-box;
            width: 100%;
            padding: 0rem 0.1rem;
            height: @topHeight - 0.4rem;
            border: none;
            outline: none;
            background-image: url();
            background-repeat: no-repeat;
            background-position: center;
            background-size: 0.4rem;
            background-color: @gray-ee;
            border-radius: 0.1rem;
            &:focus {
                background-image: none;
                border: 1px solid @blue;
            }
        }
    }
    > .nav-btn {
        flex-grow: 1;
        text-align: center;
        color: @blue;
        cursor: pointer;
        font-size: 0.36rem;
        // display: none;
    }
}
</style>